function queryManagerForm(pageIndex,pageSize)
{
          var url =base+"/admin/userList.do?pageIndex="+pageIndex+"&pageSize="+pageSize;
          var params =jQuery("#queryForm").serialize();
          params=decodeURIComponent(params,true); 
          jQuery("#managerContent").load(url+"&"+ encodeURI(encodeURI(params)));
}
 
function changeUserStatus(userId,userStatus)
{ 
        var url=base + "/admin/changeUserStatus.do";
        userStatus =(status=="normal"?"stop":"normal");
        jQuery.post(
                       url,
                      {userId:userId,userStatus:userStatus},
                      function(result){
                         var data = eval("("+result+")");
                         if(data.STATUS==0)
                         {
                            alert("修改成功!");
                            queryManagerForm(1,15);
                            return ;
                         }
                         alert(data.MSG);  
        }); 
}

/***/
function toEditAdmin(userId)
{
       location.href=base+"/admin/toEditUserInfo.do?userId="+userId;
}

function gotoPage(pageSize)
{
        var pageIndex =jQuery("#pageIndex").val();
        queryManagerForm(pageIndex,pageSize);
}


function addRegUserInfo()
{
     location.href=base+"/admin/toRegUserInfo.do";
}

function saveManager()
{   
	     var userLoginName =jQuery("#userLoginName").val();
	     var userPassword = jQuery("#userPassword");
	     var confirmUserPassword=jQuery("#confirmUserPassword");
	     if(!userLoginName)
	     {
	    	 alert("登录名不能为空。");
	    	 return jQuery("#userLoginName").select();
	     }
	     if(userPassword.length>0&&!userPassword.val())
	     {
	    	 alert("登录密码不能为空。");
	    	 return jQuery(userPassword).select();
	     }
	     if(confirmUserPassword.length>0&&!confirmUserPassword.val())
	     {
	    	 alert("确认密码不能为空。");
	    	 return jQuery(confirmUserPassword).select();
	     }
	     if(userPassword.length>0&&confirmUserPassword.length>0)
	     {
	    	 if(confirmUserPassword.val()!=userPassword.val())
	    	 {
	        	 alert("两次输入密码不一致。");
		    	 return jQuery(confirmUserPassword).select(); 
	    	 } 
	     }
         jQuery("#managerForm").ajaxSubmit(
           {
              type:"post",
              clearForm: false,        // 是否清空form  
              resetForm: true,       // 是否重置form  
              success:function(data)
              { 
                 var d= eval("("+data+")");
                 if(d.STATUS=="0")
                 {
                    alert("保存成功!");
                    location.href=base+"/admin.do";
                 }
                 else
                 {
                    alert(d.MSG);
                 }
              }
           }
          );
}


function updateUserInfo()
{
       var newPassword =jQuery("#newPassword").val();
       var confirmUserPassword=jQuery("#confirmUserPassword").val();
       var oldPassword=jQuery("#oldPassword").val();
       var userName=jQuery("#userName").val();
       if(!userName)
       {
    	   jQuery("#userName").select();
    	   return alert("用户昵称不能为空，请填写昵称!");   
       }
       if(oldPassword)//填写旧密码
       {
    	   if(!newPassword)
    	   {
    	  	   jQuery("#newPassword").select();
        	   return alert("新密码不能为空，请填写!");  
    	   }
    	   if(!confirmUserPassword)
    	   {
    	  	   jQuery("#confirmUserPassword").select();
        	   return alert("确认密码不能为空，请填写!");  
    	   }
    	   if(oldPassword==newPassword)
    	   {
    	  	   jQuery("#newPassword").select();
        	   return alert("新密码与旧密码不能相同，请重新填写!");  
    	   }
    	   if(confirmUserPassword!=newPassword)
    	   {
    	  	   jQuery("#confirmUserPassword").select();
        	   return alert("新密码与确认密码不一致，请重新输入!");  
    	   }
       }
       //managerForm
       jQuery("#managerForm").ajaxSubmit(
           {
              type:"post",
              clearForm: false,        // 是否清空form  
              resetForm: false,       // 是否重置form  
              success:function(data)
              { 
                 var d= eval("("+data+")");
                 if(d.STATUS=="0")
                 {
                    alert("信息修改成功!");
                    location.href=base+"/main/homepage.do";
                 }
                 else
                 {
                    alert(d.MSG);
                 }
              }
           }
          );
}